
from django.views.decorators.csrf import csrf_exempt
from rest_framework.generics import ListAPIView

from django.http import JsonResponse

# Create your views here.
from rest_framework.decorators import api_view

@csrf_exempt#允许跨域访问
@api_view(['GET'])
def add_book(request):
    print("我日你嘴")
    response = {}
    try:
        print("????")
        response['list'] = {"data": "小伙子什么车啊"}
        response['msg'] = 'success'
        response['error_num'] = 0
        return JsonResponse(response)
    except  Exception as e:
        response['msg'] = str(e)
        response['error_num'] = 1
        return JsonResponse(response)


class ShowTest(ListAPIView):
    def get(self,request):
        response = {}
        print("日你妈哦")
        try:
            print("????")
            response['list'] = {"data":"算你牛逼"}
            response['msg'] = 'success'
            response['error_num'] = 0
            return JsonResponse(response)
        except  Exception as e:
            response['msg'] = str(e)
            response['error_num'] = 1
            return JsonResponse(response)